package com.bw.BaseCore.mvvm

import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity

abstract class BaseActivity: AppCompatActivity() {

    protected abstract fun generateViewBindingRoot(): View

    protected open fun setupView(){}

    protected open fun initData(){}

    protected open fun handleEvent(){}


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(generateViewBindingRoot())
        setupView()     //设置视图
        initData()      //初始数据
        handleEvent()   //处理事件
    }




    /*override fun onRestoreInstanceState(savedInstanceState: Bundle) {
        super.onRestoreInstanceState(savedInstanceState)
    }

    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
    }*/

    protected fun toast(msg: String){
        Toast.makeText(this@BaseActivity, msg, Toast.LENGTH_SHORT).show()
    }
}